package com.yc.sole.erp.controller;

import com.yc.sole.erp.biz.StatisticsBiz;
import com.yc.sole.erp.request.StatisticsReq;
import com.yc.sole.erp.response.StatisticsSaleOrderResp;
import com.yc.sole.framework.result.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yizuomin
 * @date 2024/1/18 17:13
 **/
@Slf4j
@RestController
@RequiredArgsConstructor
public class StatisticsController {

    private final StatisticsBiz statisticsBiz;

    /**
     * 销售订单数量统计 15天 30天 60天...
     *
     * @return
     */
    @PostMapping("/api/erp/statistics/saleOrderQuantity")
    public Result<List<StatisticsSaleOrderResp>> saleOrderQuantity(@RequestBody StatisticsReq req) {
        return Result.data(statisticsBiz.statisticsSaleOrderQuantity(req));
    }

    /**
     * 白班、夜班 产量统计
     *
     * @return
     */
    @PostMapping("/api/erp/statistics/shiftOutput")
    public Result<List<StatisticsSaleOrderResp>> statisticsShiftOutput(@RequestBody StatisticsReq req) {
        return Result.data(statisticsBiz.statisticsShiftOutput(req));
    }

    /**
     * 客户订单金额top10
     *
     * @return
     */
    @PostMapping("/api/erp/statistics/customerAmount")
    public Result<List<StatisticsSaleOrderResp>> statisticsOrderAmount(@RequestBody StatisticsReq req) {
        return Result.data(statisticsBiz.statisticsCustomerOrderAmount(req));
    }


    /**
     * 客户订单数量top10
     *
     * @return
     */
    @PostMapping("/api/erp/statistics/customerQuantity")
    public Result<List<StatisticsSaleOrderResp>> statisticsOrderQuantity(@RequestBody StatisticsReq req) {
        return Result.data(statisticsBiz.statisticsCustomerOrderQuantity(req));
    }

    /**
     * 热销产品产量top10
     *
     * @return
     */
    @PostMapping("/api/erp/statistics/productQuantity")
    public Result<List<StatisticsSaleOrderResp>> statisticsProduct(@RequestBody StatisticsReq req) {
        return Result.data(statisticsBiz.statisticsProductQuantity(req));
    }

    /**
     * 本月、本年 应收款 已收款
     *
     * @return
     */
    @PostMapping("/api/erp/statistics/customerPayment")
    public Result<List<StatisticsSaleOrderResp>> statisticsCustomerPayment(@RequestBody StatisticsReq req) {
        return Result.data(statisticsBiz.statisticsCustomerPayment(req));
    }
}
